package Test;

import javax.swing.*;
import java.awt.*;

/*
    BorderLayout:边框布局模式
 */
public class BorderLayoutDemo {
    public static void main(String[] args) {
        JFrame win = new JFrame();
        JPanel panel = new JPanel();

        //设置布局模式
        panel.setLayout(new BorderLayout());

        //按钮组件
        JButton b1 = new JButton("东");
        JButton b2 = new JButton("西");
        JButton b3 = new JButton("南");
        JButton b4 = new JButton("北");
        JButton b5 = new JButton("中");

        panel.add(b1, BorderLayout.EAST);
        panel.add(b3,BorderLayout.SOUTH);
        panel.add(b2,BorderLayout.WEST);
        panel.add(b4,BorderLayout.NORTH);
        panel.add(b5,BorderLayout.CENTER);

        win.add(panel);
        win.setSize(600,600);
        win.setVisible(true);

    }
}
